<template>
  <div>
    <van-nav-bar
      title="收藏列表"
      left-arrow
      @click-left="onClickLeft"
      type="primary"
    />
    <van-list
      v-model="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <div class="Box" v-for="(item, index) in list" :key="index">
        <div>
          <img
            class="HouseItem_imG"
            :src="`http://liufusong.top:8080` + item.houseImg"
            alt="图片损坏，报错与我无关"
          />
        </div>
        <div>
          <h3 class="HouseItem">{{ item.title }}</h3>
          <span class="HouseItem_desc">{{ item.desc }}</span>
          <div>
            <span
              class="HouseItem_tag"
              v-for="(item, index) in item.tags"
              :key="index"
              >{{ item }}</span
            >
          </div>
          <div class="HouseItem_price">
            <span class="HouseItem_priceNum">{{ item.price }}</span> 元/月
          </div>
        </div>
      </div>
    </van-list>
  </div>
</template>

<script>
import { Favorites } from '../api/user'
export default {
  name: 'My-vue',
  data () {
    return {
      list: [],
      loading: false,
      finished: false
    }
  },

  methods: {
    async onLoad () {
      const res = await Favorites()
      console.log(res)
      this.list = res.body
      if (this.list.length === res.body.length) {
        this.finished = true
      }
    },
    onClickLeft () {
      this.$router.back()
    }
  }
}
</script>

<style>
* {
  box-sizing: border-box;
}
.Box {
  height: 120px;
  border-bottom: 1px solid #e5e5e5;
  line-height: 22px;
}
.HouseItem_imG {
  float: left;
  width: 106px;
  height: 80px;
  margin-top: 18px;
  margin-right: 12px;
}
.HouseItem {
  margin: 0;
  font-size: 15px;
  color: #394043;
  margin-top: 15px;
}
.HouseItem_desc {
  font-size: 12px;
  color: #afb2b3;
}
.HouseItem_tag {
  color: #39becd;
  background: #e1f5f8;
  display: inline-block;
  font-size: 12px;
  border-radius: 3px;
  padding: 4px 5px;
  margin-right: 5px;
  line-height: 12px;
}
.HouseItem_price {
  font-size: 12px;
  color: #fa5741;
}
.HouseItem_priceNum {
  font-size: 16px;
  font-weight: bolder;
}
</style>
